
const {ethers} = require("ethers");

const scJson = require('../artifacts/contracts/Lock.sol/Lock.json');
const abi = scJson.abi; //require('./Lock.json');
class LockSc {
    constructor(nodeUrl,scAddr) {
        this.provider = new ethers.JsonRpcProvider(nodeUrl);
        this.scInstace = new ethers.Contract(scAddr, abi, this.provider);
        
    }
    async sendCond(wallet, data) {
        let signer = wallet.connect(this.provider);
        let signedSc = this.scInstace.connect(signer);
        let ret = await signedSc.sendCoin(data,{
            gasLimit:10000000,
        });
        console.log(ret);
    }
    async encodeData(wallet, data1, data2, data3) {
        let signer = wallet.connect(this.provider);
        let signedSc = this.scInstace.connect(signer);
        let ret = await signedSc.encodeData(data1, data2, data3,{
            gasLimit:10000000,
        });
        console.log(ret);
    }
    async encodePackData(wallet, data1, data2, data3) {
        let signer = wallet.connect(this.provider);
        let signedSc = this.scInstace.connect(signer);
        let ret = await signedSc.encodePackData(data1, data2, data3,{
            gasLimit:10000000,
        });
        console.log(ret);
    }
    async encodeUint(wallet, data1) {
        let signer = wallet.connect(this.provider);
        let signedSc = this.scInstace.connect(signer);
        let ret = await signedSc.encodeUint(data1,{
            gasLimit:10000000,
        });
        console.log(ret);
    }
}

module.exports = LockSc;